package org.ch00.test04.demo07.demo02;

import java.util.Random;

/**
 * 小偷
 * @author CSY
 * @date 2025 - 03 - 04
 */
public class Thief {
    public void steal(Door door) {
        int status = new Random().nextInt(10);
        door.open();
        //判断是否实现接口
        if(door instanceof Ability){
            ((Ability) door).antiTheft();
        }
        if(status > 7){
            System.out.println("偷盗成功!");
        }else{
            System.out.println("偷盗失败!");
        }
    }

}
